﻿using System;

namespace dazhe
{
    public class Cash
    {
        public virtual double acceptCash(double money)
        {
            return 0;
        }
    }

    internal class CashNormal : Cash
    {
        public override double acceptCash(double money)
        {
            return money;
        }
    }

    internal class CashRebate : Cash
    {
        private double moneyRebate = 0;

        public CashRebate(string moneyRebate)
        {
            this.moneyRebate = double.Parse(moneyRebate);
        }

        public override double acceptCash(double money)
        {
            return money * moneyRebate;
        }
    }

    internal class CashReturn : Cash
    {
        private double moneycondition = 0;
        private double moneyreturn = 0;

        public CashReturn(string moneycondition, string moneyreturn)
        {
            this.moneycondition = Convert.ToDouble(moneycondition);
            this.moneyreturn = Convert.ToDouble(moneyreturn);
        }

        public override double acceptCash(double money)
        {
            double result = money;
            if (money >= moneycondition)
            {
                result = money - Math.Floor(money / moneycondition) * moneyreturn;
            }

            return result;
        }
    }
}